package com.kimi.commons;

import lombok.Data;

import java.io.Serializable;

/**
 * 统一响应结果
 */
@Data
public class Result<T> implements Serializable {

    private Integer code; //编码
    private String msg; //信息
    private T data; //数据
    private String desc;//描述

    public Result(Integer code, String msg, String desc, T data) {
        this.code = code;
        this.msg = msg;
        this.desc = desc;
        this.data = data;

    }

    public Result(Integer code, String msg, T data) {
        this(code, msg, "", data);
    }

    public Result(Integer code, T data) {
        this(code, "", "", data);
    }
    public Result(ErrorCode errorCode) {
        this(errorCode.getCode(), errorCode.getMsg(), errorCode.getDesc(), null);
    }
}